<?php
include_once '../tools/DBtools.php';

$accountCode = $_POST['AccountCode'];
$accountPhone = $_POST['AccountPhone'];
$realName = $_POST['RealName'];


if (empty($accountCode) || empty($accountPhone) || empty($realName)){
    echo '请完善开户信息! <a href="openAccount.php">返回开户页面</a>';
}

//连接数据库
DBtools::InitDB();


$sql = "select * from accountinfo where AccountCode = '$accountCode'";
$bb = DBtools::select($sql);
if (!empty($bb)){
    echo '该账户已存在！<a href="openAccount.php">返回开户页面</a>';
    die;
}

//添加记录
$sql = "insert into accountinfo(AccountCode,AccountPhone,RealName,OpenTime)
values('$accountCode','$accountPhone','$realName',NOW())";
$result = DBtools::noselect($sql);

if ($result['status']){
    echo '开户成功！<a href="../index.php">返回大厅</a>';
}else{
    echo '开户失败！<a href="openAccount.php">返回开户页面</a>';
}
//关闭连接
DBtools::close();